package com.example.module_vistor

import android.view.LayoutInflater
import android.widget.Toast
import androidx.activity.viewModels
import androidx.databinding.DataBindingUtil
import com.alibaba.android.arouter.facade.annotation.Route
import com.example.lib_common.base.BaseActivity
import com.example.module_vistor.databinding.ActivityVisitorBinding
import com.example.module_vistor.databinding.ItemYuekavisiterBinding
import com.example.module_vistor.visiternet.viewmodel.VisiterViewModel
import com.tencent.mmkv.MMKV
import dagger.hilt.android.AndroidEntryPoint

@Route(path = "/module_vistor/VisitorActivity")
@AndroidEntryPoint
class VisitorActivity : BaseActivity<VisiterViewModel, ActivityVisitorBinding>() {
    override val mLayoutResId: Int
        get() = R.layout.activity_visitor
    lateinit var item_visiterbinding: ItemYuekavisiterBinding
    val viewModel: VisiterViewModel by viewModels()

    override fun initView() {
        searchbinding()
        val s = MMKV.defaultMMKV().decodeInt("userid")
        viewModel.getVisiterInfo(s)




    }

    private fun searchbinding() {
        item_visiterbinding = DataBindingUtil.inflate(
            LayoutInflater.from(this),
            R.layout.item_yuekavisiter,
            mBinding.visiterFramlayout,
            false
        )

        mBinding.visiterFramlayout.addView(item_visiterbinding.root)
    }

    override fun initData() {
        super.initData()
        item_visiterbinding.back.setOnClickListener {
            finish()
        }



        viewModel.visiterfailedlivedata.observe(this){
//            Toast.makeText(this, ""+it, Toast.LENGTH_SHORT).show()
        }
        viewModel.visitersuccesslivedata.observe(this){
//            Toast.makeText(this, ""+it.userId, Toast.LENGTH_SHORT).show()
        }

    }

    override fun initListener() {
        super.initListener()
    }

}

